extends "res://Weapon/scripts/WeaponCommon.gd"

@onready var bullet = load("res://Bullet/tscn/Bullet.tscn")
# 圆形弹幕的枪

@export var bullectNum = 8		## 子弹数量
@export var radius = 15.0		## 圆环半径

func fire():
	power = bulletPower * state.power
	if !isFire:
		audio.play()
		fireTimer.start()
		
		# 基础方向（朝向鼠标）
		var baseDirection = (get_global_mouse_position() - global_position).normalized()
		
		# 生成扩散圆环弹幕
		for i in range(bullectNum):
			var bullet = self.bullet.instantiate()
			bullet.speed = bulletSpeed
			bullet.power = self.power
			
			# 计算子弹在圆环上的角度
			var angle = i * (2 * PI / bullectNum)
			var offset = Vector2(cos(angle), sin(angle)) * radius
			bullet.position = shootPosition.global_position + offset
			bullet.direction = baseDirection
			
			get_tree().root.add_child(bullet)
		
		isFire = true
